﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KOPLibrary.SharePointManagement;

namespace KOPLibrary.Forms
{
    public partial class SPTasksForm : Form
    {
        public SPTasksForm(TaskDataList tdl)
        {
            InitializeComponent();
            InitUI(tdl);
        }

        private void InitUI(TaskDataList tdl)
        {
            if (tdl != null)
            {
                ListViewItem lvi;
                foreach (TaskData item in tdl)
                {

                    lvi = new ListViewItem();
                    
                    lvi.BackColor = item.Status.Trim() == "Completed" ? Color.FromArgb(145, 206, 124) : Color.FromArgb(249, 119, 119);
                    lvi.StateImageIndex = item.Status.Trim() == "Completed" ? 0 : 1;                    
                    lvi.Text = item.Status;                    
                    lvi.SubItems.Add(item.Outcome);
                    lvi.SubItems.Add(item.AssignedTo);
                    lvi.SubItems.Add(item.Title);
                    lvi.SubItems.Add(item.CreateDate);
                    lvi.SubItems.Add(item.StartDate);
                    lvi.SubItems.Add(item.ModifyDate);
                    lvi.SubItems.Add(item.DueDate);                    
                    ctlList.Items.Add(lvi);
                }
                ctlList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}
